﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Having.Site.Base.comm
{
    public class HttpOffer
    {
        /// <summary>
        /// 请求的url
        /// </summary>
        public string Url { set; get; }
        /// <summary>
        /// 请求的data(post)
        /// </summary>
        public string Data { set; get; }
        /// <summary>
        /// 请求的编码
        /// </summary>
        public Encoding Encod { set; get; }
        /// <summary>
        /// 超时时间（毫秒）
        /// </summary>
        public int Timeout { set; get; }
        /// <summary>
        /// 请求的类型
        /// </summary>
        public string ContentType { set; get; }
        /// <summary>
        /// 附加的头部信息
        /// </summary>
        public Dictionary<string, string> HeaderDic { set; get; }

        /// <summary>
        /// 证书的路径
        /// </summary>
        public string CertPath { set; get; }
        /// <summary>
        /// 证书的密码
        /// </summary>
        public string CertKey { set; get; }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="_Url">请求的url</param>
        /// <param name="_Data">请求的data(post)</param>
        /// <param name="_Encod">请求的编码</param>
        /// <param name="_Timeout">超时时间（毫秒）</param>
        /// <param name="_ContentType">请求的类型</param>
        /// <param name="_HeaderDic">附加的头部信息</param>
        /// <param name="_CertPath">证书的路径</param>
        /// <param name="_CertKey">证书的密码</param>
        public HttpOffer(string _Url, string _Data="", Encoding _Encod = null, int _Timeout = 60000, string _ContentType = "application/x-www-form-urlencoded", Dictionary<string, string> _HeaderDic = null, string _CertPath = null, string _CertKey = null)
        {
            this.Url = _Url;
            this.Data = _Data;
            this.Encod = _Encod ?? Encoding.UTF8;
            this.Timeout = _Timeout;
            this.ContentType = _ContentType;
            this.HeaderDic = _HeaderDic;
            if (!string.IsNullOrWhiteSpace(_CertPath) && !string.IsNullOrWhiteSpace(_CertKey))
            {
                this.CertPath = _CertPath;
                this.CertKey = _CertKey;
            }
            

        }
    }

}
